package com.example.securitydemo.service;


import com.example.securitydemo.model.Authority;
import com.example.securitydemo.model.IUser;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    public IUser getUser(String username) {

      IUser user=null;
//        Object o = redisTemplate.opsForValue().get("customer_"+username);
//        if(o!=null){
//            user=(IUser) o;
//        }else {
//            customer = customerRepository.findByUsername(username);
//            if(user!=null){
//                redisTemplate.opsForValue().set("customer_"+username,customer);
//            }
//        }
        return user;

    }

    public List<Authority> getCustomerAuthority(String s) {


        List<Authority> authorities=null;
//        Object o = redisTemplate.opsForValue().get("authorities_"+username);
//        if(o!=null){
//            authorities=(List<Authority>)o;
//        }else {
//            authorities=authorityRepository.findAuthoritiesByUsername(username);
//            if(authorities.size()>0){
//                redisTemplate.opsForValue().set("authorities_"+username,authorities);
//            }
//        }
        return authorities;

    }
}
